# @Author ZhangGJ
# @Date 2021/12/09 09:34

# 读取文件所有内容
def read():
    with open('file_reader_3.py') as f:
        print(f.read())


# 逐行读取
def read_line():
    with open('file_reader_3.py') as f:
        for line in f:
            # rstrip 去除多余的换行
            print(line.rstrip())


# 读取每一行存储进列表中
def read_list():
    with open('file_reader_3.py') as f:
        line_list = f.readlines()
    for line in line_list:
        print(line.rstrip())


# 写入文件
# w 写入模式 -- 会覆盖文件的内容
# r 读取模式
# a 附加模式
# r+ 读写模式
# 默认r模式
def write():
    with open('test.txt', 'w') as f:
        f.write('Hello')


# 附加模式
def write_a():
    with open('test.txt', 'a') as f:
        f.write('==========Hello')


if __name__ == '__main__':
    write_a()
